-
-
Notifications
You must be signed in to change notification settings - Fork 23
v2.1.0 #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v2.1.0 #108
Conversation
I need some support on the return type hint for Since the decorator is polymorphic, I can't figure out how to annotate how this decorator can be used with or without parenthesis. The current annotations do not work properly when parenthesis are used, such as in our tests. |
You'd handle that polymorphic behavior with |
Support on that would be great. You can either commit it directly to this branch, or we can push this PR forward and PR proper type hints later. |
Here's a sample of what the overload might look like: @overload
def view_to_component(view: Callable | View) -> _ViewComponentConstructor: ...
@overload
def view_to_component(view: None = ..., other_params: Any) -> Callable[[Callable], _ViewComponentConstructor]: ...
# final definition
def view_to_component(view: Callable | View | None = None, other_params: Any) -> _ViewComponentConstructor | Callable[[Callable], _ViewComponentConstructor]: ... |
Dang, overload is pretty neat. I needed to do some modifications in order for the type hints to also work for use cases such as: _view_to_component_kwargs = view_to_component(views.view_to_component_kwargs, compatibility=True) I believe I got something pretty solid in terms of type hints. But I'm not sure why the github actions mypy has issues with it when my local |
@rmorshea not sure why my local MyPy doesn't generate warnings but GitHub actions does. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general there seem to be a bunch of type: ignore
comments that could potentially be resolved in a better way. Let's see if we can remove those. If not, could you comment with the reason?
For the ignore comments in our tests, I don't think those are necessary seeing as we don't actually type check our tests. If your IDE is showing type errors in those files, let's add an exclude pattern to our config.
I think it's worthwhile to keep the ignores in |
Perhaps we should run |
Done |
Hopefully we can push this out today. I'd like to get the VTC security warning on the docs ASAP |
I think we can merge this, but I'm a little uncertain whether running MyPy against our test suite is the right move. I'm worried that the benefits of doing so don't outweigh the burden it might places on potential contributors. MyPy allows for per-module configuration, so perhaps, in a follow-up PR, we could tweak our MyPy configuration for our tests to be more lenient than the configuration we apply to our tests. |
I don't mind not running the test suite on the Increasing test leniency might reduce the API/typehint bugs I manually catch while writing test. |
MyPy is pretty configurable so I'm pretty sure we could strike a nice balance. |
Changelog
view_to_component
callable to haverequest
argument be optional.channels>=4.0.0
.view_to_component
docsview_to_component
when usingcompatibility=True
.Checklist:
Please update this checklist as you complete each item:
changelog.rst
has been updated with any significant changes, if necessary.